package com.cn.jdia.mq.db;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ConfigConstructor {

	public static List<Map<String, String>> getConfig() {
		List<Map<String, String>> list = new ArrayList<>();

		DBManager4Mysql db = DBManager4Mysql.createInstance();
		db.connectDB();

		String sql = "select * from mqconfig";

		String severname = null;
		String ip = null;
		String port = null;
		String mqcontent = null;
		String mode = null;
		String mqtype = null;

		try {
			ResultSet rs = db.executeQuery(sql);
			while (rs.next()) {
				Map<String,String> map=new HashMap<>();
				
				severname = rs.getString("servername");
				ip = rs.getString("ip");
				port = rs.getString("port");
				mqcontent = rs.getString("mqcontent");
				mode = rs.getString("mode");
				mqtype = rs.getString("mqtype");
				
				map.put("severname", severname);
				map.put("ip", ip);
				map.put("port", port);
				map.put("mqcontent", mqcontent);
				map.put("mode", mode);
				map.put("mqtype", mqtype);
				
				list.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		db.closeDB();
		return list;
	}
}
